<div class="tab_item" style="display: block">
    <div class="toolbar clearfix">
        <div class="float_right">

        </div>
        <h3>换电订单</h3>
    </div>
    <div class="grid" style="height:345px;">
        <table id="page_table_box_${pid}"></table>
    </div>
</div>

<script>
    $(function () {
        $('#page_table_box_${pid}').datagrid({
            fit: true,
            width: '100%',
            height: '100%',
            striped: true,
            pagination: true,
            url: "${contextPath}/security/hdw/exchange_order/page.htm?customerId=${customerId}",
            fitColumns: true,
            pageSize: 10,
            pageList: [10, 50, 100],
            idField: 'id',
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            autoRowHeight: false,
            rowStyler: gridRowStyler,
            columns: [
                [
                    {
                        title: '订单编号',
                        align: 'center',
                        field: 'orderId',
                        width: 70,
                        formatter: function (val, row) {
                            return row.id;
                        }
                    },
                    {
                        title: '状态',
                        align: 'center',
                        field: 'orderStatusName',
                        width: 30
                    },
                    {
                        title: '充电柜/旧电池箱号/新电池箱号',
                        align: 'center',
                        field: 'cabinetId',
                        width: 80,
                        formatter: function (val, row) {
                            return row.cabinetId + '/' + row.firstBoxNum + '/' + row.secondBoxNum;
                        }
                    },
                    {
                        title: '金额(元)',
                        align: 'center',
                        field: 'price',
                        width: 30,
                        formatter: function (val, row) {
                            return new Number(val / 100).toFixed(2);
                        }
                    },
                    {
                        title: '下单时间',
                        align: 'center',
                        field: 'createTime',
                        width: 60
                    },
                    {
                        title: '操作',
                        align: 'center',
                        field: 'id',
                        width: 40,
                        formatter: function (val, row) {
                            var html = '<a href="javascript:view_order(\'ID\')">查看</a>';
                            if (row.orderStatus == 4) {
                                html += ' <a href="javascript:divide(\'ID\')">金额分配</a>'
                            }
                            return html.replace(/ID/g, row.id);
                        }
                    }
                ]
            ],
            onLoadSuccess: function () {
                $('#page_table_box_${pid}').datagrid('clearChecked');
                $('#page_table_box_${pid}').datagrid('clearSelections');
            }
        })
    })

    function view_order(id) {
        App.dialog.show({
            css: 'width:776px;height:420px;',
            title: '查看',
            href: "${contextPath}/security/hdw/exchange_order/view.htm?id=" + id
        });
    }
    function divide(id) {
        App.dialog.show({
            css: 'width:776px;height:440px;',
            title: '金额分配',
            href: "${contextPath}/security/hdw/exchange_order_money_divide/divide.htm?orderId=" + id
        });
    }
</script>